<?php include PATH_TPL."/tpl_header.html" ?>
<script type="text/javascript">
$(function() {
	$("#accounts-menu").addClass('in');
	$('#oldPwd').focus();
	$('#submit').click(function() {
		var oldPwd      = $('#oldPwd').val();
		var newPwd      = $('#newPwd').val();
		var confirmPwd  = $('#confirmPwd').val();

		if (oldPwd == '') {
			$('.oldPwdMsg').css('display','block').html('请输入旧密码');
			$('#oldPwd').focus(function(){
				$('.oldPwdMsg').css('display','none');
			});
			return false;
		}
		
		if (newPwd.length < 6) {
			$('.newPwdMsg').css('display','block').html('密碼至少为6位!');
			$('#newPwd').focus(function(){
				$('.newPwdMsg').css('display','none');
			});
			return false;
		}
		
		if (newPwd == '') {
			$('.newPwdMsg').css('display','block').html('请输入新密碼!');
			$('#newPwd').focus(function(){
				$('.newPwdMsg').css('display','none');
			});
			return false;
		}
		if (confirmPwd == '' || newPwd != confirmPwd) {
			$('.confirmPwdMsg').css('display','block').html('两次输入的密码不一致!');
			$('#confirmPwd').focus(function(){
				$('.confirmPwdMsg').css('display','none');
			});
			return false;
		}

		$.post('/index.php/reset-password', {oldPwd:oldPwd,newPwd:newPwd,confirmPwd:confirmPwd}, 
			function(data) {
			if (data.status == true) {
				location.href = '/index.php/reset-password-success/';
			} else {
				switch(data.data){
					case 1:
						$('.commonMsg').css('display','block').html(data.info);
						return false;break;
					case 6:
						$('.oldPwdMsg').css('display','block').html(data.info);
						$('#oldPwd').val('');
						$('#oldPwd').focus(function(){
							$('.oldPwdMsg').css('display','none');
						});
						return false;break;
					case 7:
						$('.confirmPwdMsg').css('display','block').html(data.info);
						$('#confirmPwd').val('');
						$('#confirmPwd').focus(function(){
							$('.confirmPwdMsg').css('display','none');
						});
						return false;break;
				}
			}
		}, 'json');
	});
});
</script>

	<div class="header">
        <h1 class="page-title">系统操作</h1>
    </div>
    <ul class="breadcrumb">
        <li><a>系统操作</a> <span class="divider">/</span></li>
        <li class="active">密码重置</li>
    </ul>
     
<div class="row-fluid">
    <div class="dialog">
        <div class="block">
            <p class="block-heading">修改密码</p>
            <div class="block-body">
                <form>
                	<div class="errMsg commonMsg"></div>
                	<div class="errMsg oldPwdMsg"></div>
                    <label for="oldPwd">*旧密码</label>
                    <input type="password" id="oldPwd" class="span12"></input>

                    <div class="errMsg newPwdMsg"></div>
                    <label for="newPwd">*新密码</label>
                    <input type="password" id="newPwd" class="span12"></input>

                    <div class="errMsg confirmPwdMsg"></div>
                    <label for="confirmPwd">*新密码确认</label>
                    <input type="password" id="confirmPwd" class="span12"></input>
                    <a id="submit" class="btn btn-primary pull-right">提交</a>
                    <div class="clearfix"></div>
                </form>
            </div>
        </div>
    </div>
</div>

<?php include PATH_TPL."/tpl_sidebar.html" ?>